<div id="categoryContainer" class="nav nav_horizontal">
<?php
	if(empty($_GET)) {
		$_GET = array('prefix' => 'ctg');
	} else {
		$_GET['prefix'] = 'ctg';
	}
	//Kategorien laden
	include 'lib/php/load.php';
	ob_end_clean();
	$categories = $items;
	$i = 0;
	//Kategorien anzeigen
	foreach ($categories as $id => $item) {
		//wurde eine Kategorie gewählt?
		if(isset($_GET['ctg_id'])) {
			//ist aktuelle Kategorie die gewählte?
			if($id == $_GET['ctg_id']) {
				$active_ctg_id = $id;
				displayCtg($id, $item, true);
			} else {
				displayCtg($id, $item, false);
			}
		//keine Kategorie gewählt, automatisch erste wählen
		} else if ($i == 0) {
			$active_ctg_id = $id;
			displayCtg($id, $item, true);
		} else {
			displayCtg($id, $item, false);
		}
		$i++;
	}
?>
</div>

<?php 
function displayCtg($id, $item, $active){
	$prefix = $item[prefix];
	$div_id = $prefix."_".$id;
	$class = $active == true ? 'item ctg active' : 'item ctg';
	$alias = $item[alias];
	$label = $item[label];
	$thumb = $item[thumb];
	$thumb_enable = $item[thumb_enable];
	$left = 80*$item[position];
	$html = array("<div id=\"$div_id\" class=\"$class\" style=\"left:".$left."px;\">
	<a id=\"innerlink_$div_id\" class=\"link\" href=\"index.php?prefix=$prefix&amp;ctg_id=$id\"></a>\n");
	if($label != "") 					array_push($html, "	<div id=\"label_$div_id\" class=\"label\">$label</div>\n");
	if($thumb != "" && $thumb_enable) 	array_push($html, "	<img id=\"thumb_$div_id\" class=\"thumb\" src=\"$thumb\" alt=\"$alias\" width=\"73\" height=\"73\" />\n");
	array_push($html, "</div>");
	echo join('', $html);
}
?>